import ajax from "./base";

import { API_CONFIG } from "./config/index"

function request({
    url,
    ...config
}) {
    let _url = API_CONFIG.API_HOST + url;
    const { param } = config;
    if (param) {
        const arrKey = Object.keys(param);
        arrKey.forEach((key, index) => {
            if (index === 0) {
                _url += `?${key}=${param[key]}`;
                return;
            }
            _url += `&${key}=${param[key]}`;
        })
    }
    return ajax({
        ...config,
        url: _url,
    })
}

export {
    request,
    API_CONFIG
};